<template>
<div>
  
  <el-table
    :data="tableData"
      height="250"
    style="width: 100%"
    :row-class-name="tableRowClassName">
    <el-table-column 
      
      fixed
      prop="date"
      label="日期"
      width="150">
    </el-table-column>
    <el-table-column
     id="2"
     prop="name"
      label="姓名"
      width="120">
    </el-table-column>
    <el-table-column
     id="3"
     prop="province"
      label="省份"
      width="120">
    </el-table-column>
     <el-table-column
      id="4"
      prop="city"
      label="市区"
      width="120">
    </el-table-column>
    <el-table-column
      id="5" 
      prop="address"
      label="地址"
      width="300">
    </el-table-column>
    <el-table-column
      id="6"
      prop="zip"
      label="邮编"
      width="120">
    </el-table-column>
 <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
        <el-button type="text" size="small">编辑</el-button>
      </template>
    </el-table-column>
  </el-table>
  <div class="block">
  <el-pagination
    layout="prev, pager, next"
    :total="50">
  </el-pagination>
</div>
  </div>
</template>



<style>
  .el-table .warning-row {
    background: oldlace;
  }

  .el-table .success-row {
    background: #f0f9eb;
  }
  
</style>

<script>
  export default {
    methods: {
      tableRowClassName({row, rowIndex}) {
        if (rowIndex === 1) {
          return 'warning-row';
        } else if (rowIndex === 3) {
          return 'success-row';
        }else if (rowIndex === 5) {
          return 'warning-row';
        }else if (rowIndex === 7) {
          return 'success-row';
        }
        return '';
      },
      handleClick(row) {
        console.log(row);
      }
    },
    
    data() {
      return {
        tableData: [{
           date: '2016-05-02',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }, {
          date: '2016-05-02',
          name: '李逍遥',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }, {
           date: '2016-05-02',
          name: '景天',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }, {
           date: '2016-05-02',
          name: '重楼',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }, {
           date: '2016-05-02',
          name: '唐钰小宝',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }, {
           date: '2016-05-02',
          name: '徐长卿',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }, {
           date: '2016-05-02',
          name: '虹猫',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }]
      
      }
    }
  }
</script>